package com.ibeeking.found.file.service.common.dos;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@TableName("user_file")
public class UserFileDO implements Serializable {
    private static final long serialVersionUID = -1L;

    @TableId(type = IdType.ASSIGN_ID)
    private Long userFileId;

    /**
     * 用户id
     */
    @TableField(value = "user_id")
    private Long userId;

    /**
     * 文件id
     */
    @TableField(value = "user_id")
    private Long fileId;

    /**
     * 文件名
     */
    @TableField(value = "file_name")
    private String fileName;

    /**
     * 文件路径
     */
    @TableField(value = "file_path")
    private String filePath;

    /**
     * 扩展名
     */
    @TableField(value = "extend_name")
    private String extendName;

    /**
     * 是否是目录(0-否,1-是)
     */
    @TableField(value = "is_dir")
    private Integer isDir;

    /**
     * 修改时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "upload_time")
    private LocalDateTime uploadTime;

    /**
     * 删除标识(0-未删除，1-已删除)
     */
    @TableField(value = "delete_flag")
    private Integer deleteFlag;

    /**
     * 删除时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "delete_time")
    private LocalDateTime deleteTime;

    /**
     * 删除批次号
     */
    @TableField(value = "delete_batch_num")
    private String deleteBatchNum;

    /**
     * 创建时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "create_time")
    private LocalDateTime createTime;

    /**
     * 创建用户id
     */
    @TableField(value = "create_by")
    private Long createBy;

    /**
     * 修改时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "modify_time")
    private LocalDateTime modifyTime;

    /**
     * 修改用户id
     */
    @TableField(value = "modify_by")
    private Long modifyBy;

    public boolean isDirectory() {
        return this.isDir == 1;
    }

    public boolean isFile() {
        return this.isDir == 0;
    }

}
